package dao;

import java.sql.Connection;
import java.sql.DriverManager;

public class BaseDao {
    private Connection connection;//声明连接对象
    public Connection getConnection() throws Exception {
        //驱动程序名
        String driver = "com.mysql.cj.jdbc.Driver";
        //URL指向要访问的数据库名MyData
        String url = "jdbc:mysql://localhost:3306/weekeight";
        //MySQL配置时的用户名
        String user = "root";
        //MySQL配置时的密码
        String password = "123456";
        //加载驱动程序
        Class.forName(driver);
        //getConnection()方法，连接MySQL数据库
        connection = DriverManager.getConnection(url,user,password);
        return connection;
    }

}